package all.request;

import all.Run;
import all.util.DubboServiceFactory;
import all.util.RequestDataHandler;
import api.UserService;
import bean.User;
import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.rpc.service.GenericService;
import com.griftt.rent.data.common.bean.RequestData;
import javassist.tools.reflect.ClassMetaobject;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 该类为 普通用户请求的唯一入口
 * @auther: Griftt wu
 * @date: 2019/9/16
 **/


@Controller
@RequestMapping("userSApi")
public class UserSGateway {


    @Reference
    UserService userService;


    @RequestMapping("info")
    @ResponseBody
    public Object handle(String hello){
        //根据方法名获取方法
       //return  DubboServiceFactory.getInstance().genericInvoke("api.IUserSApi","getmsg",null,null);
       //return  DubboServiceFactory.getInstance().genericInvoke("api.IUserSApi","getmsg",null,null);
       return  DubboServiceFactory.getInstance().genericInvoke("api.IUserSApi","getmsg",null,null);

    }

    @RequestMapping("param")
    @ResponseBody
    public Object handleParam(){
        //根据方法名获取方法
       return  DubboServiceFactory.getInstance().genericInvoke("api.IUserSApi","getmsg",null,null);

    }

    @RequestMapping("userList")
    @ResponseBody
    public Object userList(){
        //根据方法名获取方法
       return  DubboServiceFactory.getInstance().genericInvoke("service.UserRentService","findUserAll",null,null);

    }

    @RequestMapping("addUser")
    @ResponseBody
    public Object addUser(@RequestBody RequestData requestData){

        System.err.println(requestData);
        return RequestDataHandler.handleRequest(requestData);
    }

}
